package com.aistar.service.impl;

import com.aistar.mapper.ProductImagesMapper;
import com.aistar.mapper.ProductMapper;
import com.aistar.pojo.ProductImages;
import com.aistar.pojo.ProductImagesExample;
import com.aistar.service.ProductImagesService;
import com.aistar.util.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductImagesServiceImpl implements ProductImagesService {
    @Autowired
    private ProductImagesMapper productImagesMapper;

    @Override
    public ServerResponse add(ProductImages productImages) {
        return null;
    }

    @Override
    public ServerResponse modify(ProductImages productImages) {
        return null;
    }

    @Override
    public ServerResponse delete(Integer id) {
        return null;
    }

    @Override
    public ServerResponse getById(Integer id) {
      ProductImages productImages =  productImagesMapper.selectByPrimaryKey(id);
        if(productImages != null)
            return ServerResponse.getSuccess(productImages);
        return ServerResponse.getFailed("暂无数据");

    }
    @Override
    public ServerResponse getByProId(Integer id) {
        ProductImagesExample productImagesExample = new ProductImagesExample();
        productImagesExample.createCriteria().andProductIdEqualTo(id);
        List<ProductImages> productImagesList = productImagesMapper.selectByExample(productImagesExample);
        if(productImagesList != null && productImagesList.size() >0)
            return ServerResponse.getSuccess(productImagesList);
        return ServerResponse.getFailed("暂无数据");
    }

    @Override
    public ServerResponse getAll() {
        return null;
    }
}
